-- change_target_bonus
-- create by cheny3 Nov/19/2016
-- 修改奖励

return {
    apply = function(source, target, skillId, round, para, extra)
        if source.type ~= OBJECT_TYPE_MONSTER then
            return {};
        end

        -- 场上活着的怪物
        local ret = {};
        local grids = DungeonM.getCurrentDungeon();
        for _, grid in ipairs(grids) do
            if  grid:isMonster() and
                grid:isOpened() and
                not grid.monster:isDead() and
                grid.monster:query("base_class_id") == para[1] then
                table.insert(ret, grid);
            end
        end

        local bonus = {};
        for _, grid in ipairs(ret) do
            if type(para[2]) == "table" then
                bonus = para[2];
            elseif type(para[2]) == "string" then
                bonus = FormulaM.invoke(para[2], ME.user, skillId);
            end
            grid.bonus = bonus;
        end

        -- 返回作用目标
        return ret;
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), arr[2], };
    end,
};
